[gcode_macro M300]                                              # Marlin Compatibility
description: Play beep sound
gcode:
    # Use a default 1kHz tone if S is omitted.
    {% set S = params.S|default(1000.0)|float %}
    # Use a 10ms duration is P is omitted.
    {% set P = params.P|default(100)|int %}
    SET_PIN PIN="beeper" VALUE=0.5 CYCLE_TIME={ 1.0 / S }
    G4 P{P}
    SET_PIN PIN="beeper" VALUE=0
